package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.Lsh待办事项Model;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by ThinkPad on 2016/9/18.
 */
@Transactional
public interface Lsh待办事项Repository extends JpaRepository<Lsh待办事项Model, Integer>, JpaSpecificationExecutor<Lsh待办事项Model> {
    @Modifying
    @Query("update Lsh待办事项Model a set  a.是否删除='是' where a.待办编号=?1 and a.许可=?2")
    public void delAppointmentMsgById(int id, String permit);

    @Query("select a from Lsh待办事项Model a where a.附属编号=?1 and a.附属编号类型='线索' and a.是否删除='否' and a.许可=?2 order by a.更新时间")
    public List<Lsh待办事项Model> getLatestAppointmentMsg(int num, String permit);

    @Query("select a from Lsh待办事项Model a where a.许可 = ?1 and a.是否删除 = '否'")
    List<Lsh待办事项Model> findAllByDlr(String dlr);

    @Query("select a from Lsh待办事项Model a where a.许可 = ?1 and a.销售顾问 = ?2 and a.附属编号 = ?3 and a.待办分类 = '预约接待' and a.附属编号类型 = '线索' and a.待办子类 = null and a.待办小类 = null and a.是否删除 = '否'")
    List<Lsh待办事项Model> findDCCOrder(String permit, String scCode, int importId);
}
